﻿/*****************************************************************************
	SNEGA STG GAME ENGINE 0.7a
	Copyright (C) 2009, Xiaohan Tian (snega0223)
	
	http://code.google.com/p/sng-actionscript-stg-engine/
	
	This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License(LGPL) as
	published by the Free Software Foundation, either version 3 of the 
	License, or(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

package com.sng.stg.game.event 
{
	import com.sng.stg.game.StageViewer;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author snega
	 */
	public class EnemyKilled extends ContinuousEvent
	{
		protected var _killedImage:Bitmap = null;
		
		protected var _frame:int = 0;
		
		public function EnemyKilled(bitmapData:BitmapData = null, pixelSnapping:String = "auto", smoothing:Boolean = false) 
		{
			this._killedImage = new Bitmap(bitmapData, pixelSnapping, smoothing);
			this._killedImage.x = - this._killedImage.width/2;
			this._killedImage.y = - this._killedImage.height/2;
			
			this.addChild(this._killedImage);
		}
		
		override public function start(stage:StageViewer):void {
			this._stage = stage;
			
			this._stage._continuousEventList.push(this);
			this._stage._2dElement.addChild(this);
			
			this.scaleX = 0.5;
			this.scaleY = 0.5;
			this.scaleZ = 0.5;
			
			this._frame = 0;
		}
		
		override public function process():void {
			if (this._frame++ == 15) {
				this._stage._2dElement.removeChild(this);
				this.remove();
			}
			
			this.scaleX += 0.1;
			this.scaleY += 0.1;
			this.scaleZ += 0.1;
			this.alpha -= 0.05;
		}
		
	}
	
}